<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'business-form',
	'enableAjaxValidation'=>false,
)); ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">
		<?php echo $form->labelEx($model,'businessGoal'); ?>
		<?php echo $form->dropdownlist($model,'businessGoal', Business::model()->getBGoalOptions())?>
		<?php echo $form->error($model,'businessGoal'); ?>
	</div>
	
	<div class="row">
		<?php echo $form->labelEx($model,'businessStatus'); ?>
		<?php echo $form->dropdownlist($model,'businessStatus', Business::model()->getBStatusOptions())?>
		<?php echo $form->error($model,'businessStatus'); ?>
	</div>
	
	<div class="row">
		<?php echo $form->labelEx($model,'businessType_id'); ?>
		<?php echo $form->dropdownlist($model,'businessType_id', CHtml::listData(BusinessType::model()->findAll(),'id','name'));?>
		<?php echo $form->error($model,'businessType_id'); ?>
	</div>
	
<!-- enter businessResources of current business -->
	<div class="row">
	
		<?php echo $form->labelEx($model,'tblValuepropositions'); ?>
	
	<div class='checkboxes'>
	
		<?php 
			if ($model->tblValuepropositions == null)
			{
				echo $form->checkBoxList($model, 'tblValuepropositions',
            		CHtml::listData(ValueProposition::model()->findAll(), 'id', 'name'),
            		array('attributeitem' => 'id','separator'=>'<br>','labelOptions'=>array('style'=>'display:inline')) );
			}
			else 
			{
				$model2 = new Business();
				
				$valuePropositionsArray = array();
				
				foreach ($model->tblValuepropositions as $value)
				{
					array_push($valuePropositionsArray, $value->id);
				}
				$model2->tblValuepropositions = $valuePropositionsArray;


				echo $form->checkBoxList($model2, 'tblValuepropositions',
            		CHtml::listData(ValueProposition::model()->findAll(), 'id', 'name'),
            		array('attributeitem' => 'id','separator'=>'<br>','labelOptions'=>array('style'=>'display:inline')) );
			
			}
		?>
    </div>
        <?php echo $form->error($model,'tblValuepropositions'); ?>
	</div>


<!-- enter businessResources of current business -->
	<div class="row">
	
		<?php echo $form->labelEx($model,'tblBusinessresources'); ?>
	
	<div class='checkboxes'>
	
		<?php 
			if ($model->tblBusinessresources == null)
			{
				echo $form->checkBoxList($model, 'tblBusinessresources',
            		CHtml::listData(BusinessResources::model()->findAll(), 'id', 'name'),
            		array('attributeitem' => 'id','separator'=>'<br>','labelOptions'=>array('style'=>'display:inline')) );
			}
			else 
			{
				$model2 = new Business();
				
				$businessresourcesArray = array();
				
				foreach ($model->tblBusinessresources as $resource)
				{
					array_push($businessresourcesArray, $resource->id);
				}
				$model2->tblBusinessresources =	$businessresourcesArray;


				echo $form->checkBoxList($model2, 'tblBusinessresources',
            		CHtml::listData(BusinessResources::model()->findAll(), 'id', 'name'),
            		array('attributeitem' => 'id','separator'=>'<br>','labelOptions'=>array('style'=>'display:inline')) );
			
			}
		?>
    </div>
        <?php echo $form->error($model,'tblBusinessresources'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'economicSector_id'); ?>
		<?php echo $form->dropdownlist($model,'economicSector_id', CHtml::listData(EconomicSector::model()->findAll(),'id','name'))?>
		<?php echo $form->error($model,'economicSector_id'); ?>
	</div>
	
	<div class="row">
		<?php echo $form->labelEx($model,'businessSector_id'); ?>
		<?php echo $form->dropdownlist($model,'businessSector_id', CHtml::listData(BusinessSector::model()->findAll(),'id','name'))?>
		<?php echo $form->error($model,'businessSector_id'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'industryGroup_id'); ?>
		<?php echo $form->dropdownlist($model,'industryGroup_id', CHtml::listData(IndustryGroup::model()->findAll(),'id','name'))?>
		<?php echo $form->error($model,'industryGroup_id'); ?>
	</div>

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->